import { useNavigate } from 'react-router-dom';
import { useDispatch } from 'react-redux';
import { logout } from '../store/authSlice';
import AnimatedTransition from '../AnimatedTransition';

const My = () => {
    const navigate = useNavigate();
    const dispatch = useDispatch();

    const handleLogout = () => {
        dispatch(logout()); // 情况 redux 状态
        localStorage.removeItem('persist:auth'); //清除本地持久化
        // 清除本地存储的 token
        localStorage.removeItem('refreshToken');
        // Redux 退出登录
        dispatch(logout());
        // 跳转到登录页面
        navigate('/tablist/home');
    }
    return (
        <AnimatedTransition>
            <button onClick={handleLogout}>退出账号</button><br/>
            <button onClick={() => navigate('/Article')}>地点</button>
        </AnimatedTransition>
    )
}

export default My;